﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Diagnostics;
 
using System.Reflection;
using System.ServiceProcess; 

namespace NTTDATA.BEENChina.ResultCertification.Host.WindowsService
{

    partial class ServiceResultCertification : ServiceBase
    {
        public ServiceResultCertification()
        {
            InitializeComponent();
            Init();
        }

        private void Init()
        {
           

            Configuration appconfig = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
            HostConfig config = appconfig.GetSection("hostConfig") as HostConfig;
            this.ServiceName = config.ServiceName;
        }

        protected override void OnStart(string[] args)
        {
            HostConfig config = ConfigurationManager.GetSection("hostConfig") as HostConfig;
            Core.Host.GetInstance(config).Open();
        }

        protected override void OnStop()
        {
            HostConfig config = ConfigurationManager.GetSection("hostConfig") as HostConfig;
            Core.Host.GetInstance(config).Close();
        }
    }
}
